package com.fangshicai.pro_test_03;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    public static final String MESSAGE_STRING="com.fangshicai.pro_test_03.MASSAGE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btSend = findViewById(R.id.send_message);
        final EditText etMessage = findViewById(R.id.message);

        btSend.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                String messageText = etMessage.getText().toString();
                Toast.makeText(MainActivity.this,messageText,Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this,
                        MessageActivity.class);
                intent.putExtra(MESSAGE_STRING,messageText);
                startActivity(intent);
            }
        });
    }
}
